package com.mall.service;

import java.util.List;

import com.mall.ibatis.bean.ICell;
import com.mall.ibatis.bean.JQGrid;
import com.mall.ibatis.bean.SysPara;
import com.mall.ibatis.persistence.iface.SysParaDAO;
import com.mall.ibatis.persistence.DaoConfig;

import com.ibatis.dao.client.DaoManager;

public class SysParaService
{
	private static final SysParaService instance = new SysParaService();
	
	private DaoManager daoManager = DaoConfig.getDaomanager();
	
	private SysParaDAO sysParaDAO = null;
	
	private SysParaService()
	{
		sysParaDAO  = (SysParaDAO) daoManager.getDao(SysParaDAO.class);
	}
	
	public static SysParaService getInstance()
	{
		return instance;
	}
	
	
	public List<SysPara> selectAllSysPara() throws Exception
	{
		return sysParaDAO.selectAllSysPara();
	}
	
	
	public SysPara selectSysPara(SysPara sysPara)  throws Exception
	{
		return sysParaDAO.selectSysPara(sysPara);
	}
	
	
	public void insertSysPara(SysPara sysPara) throws Exception
	{
		sysParaDAO.insertSysPara( sysPara);
	}
	
	public void updateSysPara(SysPara sysPara) throws Exception
	{
		sysParaDAO.updateSysPara( sysPara);
	}
	
	public void deleteSysPara(SysPara sysPara) throws Exception
	{
		sysParaDAO.deleteSysPara(sysPara);
	}
	
	public JQGrid getSysParaList(List<SysPara> sysParaList,int page,int total) throws Exception
	{
		JQGrid jqGrid = new JQGrid();
		
		jqGrid.setPage(page);
		jqGrid.setRecord(sysParaList.size());
		jqGrid.setTotal(total);
		
		List<ICell> rowsList = jqGrid.getRowXML();
		
		
		for( SysPara sysPara :sysParaList)
		{
			rowsList.add(sysPara);
		}
		
		
		return jqGrid;
	}
	
	
	public String selectCurrentDate() throws Exception
	{
		return sysParaDAO.selectCurrentDate();
	}
	
	public String selectCurrentMonthBegin() throws Exception
	{
		
		return sysParaDAO.selectCurrentMonthBegin();
	}
	
	
}